package name.fowler.refactoring.simplestore;

import java.util.ArrayList;
import java.util.List;

/**
 * @author aifgi
 */
public class Statement {
    private final String name;
    private final double totalAmount;
    private final int frequentRenterPoints;
    private final List<RentalInfo> rentalInfos;

    public Statement(final String name, final List<RentalInfo> rentalInfos,
                     final double totalAmount, final int frequentRenterPoints) {
        this.name = name;
        this.totalAmount = totalAmount;
        this.frequentRenterPoints = frequentRenterPoints;
        this.rentalInfos = rentalInfos;
    }

    public String getName() {
        return name;
    }

    public double getTotalAmount() {
        return totalAmount;
    }

    public int getFrequentRenterPoints() {
        return frequentRenterPoints;
    }

    public List<RentalInfo> getRentalInfos() {
        return rentalInfos;
    }

    @Override
    public String toString() {
        String result = "Rental record for " + name + "\n";
        for (RentalInfo rentalInfo : rentalInfos) {
            result += rentalInfo.toString() + '\n';
        }
        result += "Amount owed is " + totalAmount + "\n";
        result += "You earned " + frequentRenterPoints + " frequent renter points.";
        return result;
    }
}
